﻿Imports MySql.Data.MySqlClient
Public Class Main

    Private Sub Main_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        MsgBox("SFG Game Suite (Beta)", vbExclamation, "SFG")
        txtreceive.Text = functions.Get_Chat_Messages()
        Ad_WB.Navigate("")
        lblGame_Money.Text = "Game Money: £ " & details.money
        lblWelcome.Text = "Welcome " & details.username & ", to SFG Game Suite"
    End Sub
    Private Sub Play_Slots() Handles PicSlots.Click
        'Slots
        SlotsGame.Show()
        MsgBox("Please be aware that the game you are entering is still in beta testing", MsgBoxStyle.Information, "SFG Slots (Beta)")
        lblGame_Money.Text = "Playing Game"
    End Sub
    Private Sub Play_Roulette() Handles PicRoulette.Click
        'Roulette
        MsgBox("Roulette is currently being coded", MsgBoxStyle.Information, "SFG Roulette")
    End Sub
    Private Sub Play_BlackJack() Handles PicBlackjack.Click
        'Blackjack
        MsgBox("Blackjack is currently being coded", MsgBoxStyle.Information, "SFG Blackjack")
    End Sub
    Private Sub Play_Bing() Handles PicBingo.Click
        'Bingo
        MsgBox("Bingo is currently being coded", MsgBoxStyle.Information, "SFG Bingo")
    End Sub
    Private Sub Show_News() Handles lblNews.Click
        'News
        txtreceive.Visible = False
        txtnews.Text = functions.Get_News()
        txtnews.Visible = True
        txtSend.Visible = False
        PicSend.Visible = False
    End Sub
    Private Sub Show_Chat() Handles lblChat.Click
        'Chat
        functions.Get_Chat_Messages()
        txtreceive.Visible = True
        txtnews.Visible = False
        txtSend.Visible = True
        PicSend.Visible = True
    End Sub
    Private Sub Show_My_Account() Handles lblMy_Account.Click
        'My Account
        account.Show()
    End Sub
    Private Sub Log_Out() Handles lblLog_Out.Click
        'Log Out
        Dim iResponce As Integer
        iResponce = MsgBox("Are You Sure You Want To Log Out", vbYesNo, "SFG Log Out")
        If iResponce = vbYes Then ' They Clicked YES!
            Application.Restart()
        Else
            'NO
        End If
    End Sub
    Private Sub lblExit_Click() Handles lblExit.Click
        'Exit
        Dim iResponce As Integer
        iResponce = MsgBox("Are You Sure You Want To Exit", vbYesNo, "SFG Exit")
        If iResponce = vbYes Then ' They Clicked YES!
            Me.Close()
        Else
            'NO
        End If
    End Sub
    Private Sub Exit_GS() Handles PicExit.Click
        'Exit
        Me.Close()
    End Sub
    Private Sub Picsend_Click() Handles PicSend.Click
        conn.connection.conn()
        Dim command = New MySqlCommand
        command.CommandText = "INSERT INTO `chat` (`from`, `timestamp`, `message`) VALUES ('" & details.username & "','" & functions.DateTimeToEpoch(Now) & "', '" & txtSend.Text & "')" 'Query to exectue.
        command.Connection = conn.connection.MyADOConnection
        Dim read = command.ExecuteReader
        conn.connection.MyADOConnection.Close()
        txtSend.Text = ""
        txtreceive.Text = functions.Get_Chat_Messages()
    End Sub
    Private Sub txtsend_TextChanged() Handles txtSend.TextChanged
        If txtSend.Text <> "" Then
            PicSend.Enabled = True
        Else
            PicSend.Enabled = False
        End If
    End Sub
    Private Sub Send_Feedback() Handles lblsf.LinkClicked
        sfb.Show()
    End Sub
    Private Sub Handle_Key_Press(ByVal sender As Object, ByVal e As Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.Enter Then
            Picsend_Click()
        End If
    End Sub

#Region "Move Title Bar"
    Dim IsMouseDown = False
    Dim startPoint
    Private Sub TitleBar_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TitleBar.MouseUp
        IsMouseDown = False
    End Sub
    Private Sub TitleBar_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TitleBar.MouseDown
        startPoint = e.Location
        IsMouseDown = True

    End Sub
    Private Sub TitleBar_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TitleBar.MouseMove
        If IsMouseDown Then
            Dim p1 = New Point(e.X, e.Y)
            Dim p2 = PointToScreen(p1)
            Dim p3 = New Point(p2.X - startPoint.X, p2.Y - startPoint.Y)
            Location = p3
        End If
    End Sub
#End Region 'Is a bit slow and buggy could do with a new better written version
End Class